home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: Help! Can't read input from keyboard!
- Date: 2 Apr 1996 06:58:50 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4jr8aa$hf8@solutions.solon.com>
- References: <4jq0ts$5mh@taniemarie.solon.com> <1APR199622404442@erich.triumf.ca>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <1APR199622404442@erich.triumf.ca>,
- P.Bennett <bennett@erich.triumf.ca> wrote:
- >In article <4jq0ts$5mh@taniemarie.solon.com>, seebs@taniemarie.solon.com (Peter Seebach) writes...
- >>gcc -g -O -Wa,ll -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
-
- >It would help if you posted the _real_ code so we would know there weren't any
- >typos...
-
- I really did, and if you compile it with that setup, you will notice that you
- get a *warning* from your assembler stating that "ll" is not a valid
- option. (With my assembler, anyway.) With an actual -Wall, of course,
- it correctly warns for the mistake.
-
- >> #include <stdio.h>
-
- >> int main(void) {
- >> int i = 0;
-
- >> (void) sscanf, "3", "%d", i;
-
- >This won't compile as is - it needs some parentheses, like:
- > (void) sscanf("3", "%d", i);
- >If this is what your real code says, then you need to change it to:
- > (void) sscanf("3", "%d", &i);
- >Since sscanf() must change i, you have to pass i's _address_, using &i.
-
- But the code *will* compile as is, and is legal; it evaluates to 0, after
- evaluating "scanf", "%d", and "i" for their side effects.
-
- >> (void) printf, "%d", i;
- >this must have some parentheses as well:
- > (void) printf("%d", i);
-
- Ditto here. Perfectly legal, just not useful.
-
- >The arguments for the sscanf() and printf() families are similar, but not
- >identical - scanf() needs the _address_ of its arguments, and printf() does
- >not. There are also some differences in the format specifiers.
-
- I knew that. :)
-
- Happy April Fools Day!
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-